package com.pdg.mcplugin.simpleconomy;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.ServicePriority;

import net.milkbowl.vault.economy.Economy;

import com.pdg.mcplugin.common.baseclasses.PluginBase;
import com.pdg.mcplugin.simpleconomy.dataproviders.DataProvider;

public class SimplEconomy extends PluginBase {
	
	private static final String VAULT = "Vault";
	private Economy economy = null;
	public Economy getEconomy(){
		if(economy==null){
			economy = new Economy_SimplEconomy(this);
		}
		return economy;
	}
	private DataProvider dataProvider = null;
	public DataProvider getDataProvider(){
		if(dataProvider==null){
			dataProvider = new DataProvider(this);
		}
		return dataProvider;
	}
	
	private ConfigurationManager configurationManager = null;
	public ConfigurationManager getConfigurationManager(){
		if(configurationManager==null){
			configurationManager = new ConfigurationManager(this);
		}
		return configurationManager;
	}

	@Override
	protected void disablePlugin() {
	}

	@Override
	protected boolean enablePlugin() {
		saveDefaultConfig();
		hookEconomy();
		return true;
	}

	private void hookEconomy() {
		Plugin plugin = getServer().getPluginManager().getPlugin(VAULT);
		if(plugin!=null){
			getServer().getServicesManager().register(Economy.class, getEconomy(), plugin, ServicePriority.Normal);
		}
	}

}
